
#ifndef UTILS_H_
#define UTILS_H_


/*
#define ONE	(1 << 16)

// Capped conversion from float to fixed.
#define FIXED(value) \
        value < -32768.0f ? -32768 : value > 32767.0f ? 32767 : (int)(value * ONE)
*/

#ifdef ANDROID
//get the ms unit time in Linux & Android
#define CLOCK(v_time) v_time.tv_sec * 1000 + v_time.tv_usec / 1000
#endif

#define FREEANDNULL(pointer) \
    if (pointer != NULL) { \
        free(pointer); \
        pointer = NULL; \
    }

#define DELETEANDNULL(pointer, isArray) \
    if (pointer != NULL) { \
		if (isArray) \
			delete [] pointer; \
		else \
			delete pointer; \
        pointer = NULL; \
    }

#ifndef PI
#define PI 3.1415926535897932f
#endif

#define DTOR (PI / 180.0f)
#define SQR(x) (x * x)

#ifndef byte
typedef unsigned char byte;
#endif /* byte */

#ifndef uint16
typedef unsigned short  uint16;
#endif /* uint16 */


#ifndef BOOL
typedef int BOOL;
#endif
/**
 * \def FALSE
 * \brief FALSE value, defined as 0 by MiniGUI.
 */
#ifndef FALSE
    #define FALSE       0
#endif
/**
 * \def TRUE
 * \brief TRUE value, defined as 1 by MiniGUI.
 */
#ifndef TRUE
    #define TRUE        1
#endif

#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG  , "AndMii", __VA_ARGS__)



#endif // UTILS_H_
